const int ledpin = 13;
const int buttonpush = 2;
int ledstate = HIGH;
long lastbuttonstate =  LOW;
long lastbuttontime = 0;
long debouncetime = 50;
long buttonstate ;

void setup()
{
 pinMode(ledpin,OUTPUT);
 pinMode(buttonpush,INPUT);
 digitalWrite(ledpin,ledstate); 
}

void loop()
{
   int reading = digitalRead(buttonpush); 
   if(reading != lastbuttonstate)
   {
       lastbuttontime = millis(); 
   }
       if((millis()-lastbuttontime)>debouncetime)
       {
         if(reading != buttonstate)
         {
             buttonstate = reading;
             if(buttonstate == HIGH)
             {
                  ledstate =!ledstate; 
             }
         }
         
         
       }
   digitalWrite(ledpin,ledstate);
   lastbuttonstate = reading;
}
